package Cache::RedisCacheProvider;

use strict;
use warnings;
use 5.010;

use Utils::Constants;
use Redis;

my $redis_client;

sub new {
    my $class = shift;
    my $self = {};

    bless $self, $class;

    return $self;
}

sub fetch_connection {
    my ($self, %args) = @_;

    # Only one connection is needed in the whole web app
    return $redis_client if defined $redis_client;
    
    if (%args) {
        $redis_client = Redis->new(%args);
    }
    else {
        $redis_client = Redis->new();
    }

    return $redis_client;
}

1;
